﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using Easydp.Controllers;
using Easydp.Models.Entities;

    /// <summary>
    /// Summary description for AjaxWebService
    /// </summary>
    /// 
    [WebService(Namespace = "http://www.easydp.net/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    [ScriptService]
    public class AjaxWebService : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod]
        public string HelloWorld(string s)
        {
            return "Hello World"+s;
        }

        #region 售票点 

        /// <summary>
        /// 通过 城市 获取售票点信息
        /// </summary>
        /// <param name="city"></param>
        /// <returns></returns>
        [WebMethod(Description="获取售票点信息  条件为城市")]
        [ScriptMethod]
        public List<TT_Agent> GetAgentListByCity(string city)
        {
            AgentController aController = new AgentController();
            return aController.GetListByCity(city);             
        }

        [WebMethod(Description="获取所有城市")]
        [ScriptMethod]
        public List<string> GetAllCity()
        {
            AgentController aController = new AgentController();
            return aController.GetAllCity();     
        }
        
        #endregion

        #region  火车站
        /// <summary>
        /// 按照车站搜索
        /// </summary>
        /// <param name="sStation"></param>
        /// <param name="eStation"></param>
        /// <returns></returns>
        /// 
        [WebMethod(Description="获取车次列表 条件为 出发站和到达站")]
        [ScriptMethod]
        public List<Easydp.Models.Entities.TT_TrainRoute> SearchByTrianStation(string sStation, string eStation)
        {
            TrainRouteController obj = new TrainRouteController();
            return obj.Search(sStation, eStation);
        }

        /// <summary>
        /// 按照车次查询
        /// </summary>
        /// <param name="trainNumber"></param>
        /// <returns></returns>
        /// 
        [WebMethod]
        [ScriptMethod]
        public List<Easydp.Models.Entities.TT_TrainRoute> SearchByTrianNumber(string trainNumber)
        {
            TrainRouteController obj = new TrainRouteController();
            return obj.Search(trainNumber);
        }
        #endregion

        #region 订单
        /// <summary>
        /// 添加新订单
        /// </summary>
        /// <returns></returns>
        /// 
        [WebMethod]
        [ScriptMethod]
        public int InsertOrder(TT_Orders obj)
        {
            return (new OrderController()).InsertOrder(obj);
        }
        #endregion

    }
